<!--
@Descripttion 数字框
@Author Bell
@Date 2021-11-16
@LastEditors Bell
@LastEditTime 2021-11-16
@property {Boolean} controls    默认值(true)      是否启用控制按钮
@property {Number}  min         默认值(-Infinity) 最小值
@property {Number}  max         默认值(Infinity)  最大值
@property {Number}  step        默认值(1)         每次递增
@property {Number}  precision   默认值(0)         小数点精度
@property {String}  width       默认值(200px)     输入框宽度
@property {Boolean} disabled    默认值(false)     是否失效
@property {String}  placeholder 默认值(请输入)     默认占位文本
@example <JYNumber v-model="xxx" />
 -->
<template>
  <el-input-number
    v-model="value"
    @input="changeVal"
    :controls="controls"
    :min="min"
    :max="max"
    :step="step"
    :precision="precision"
    :style="`width: ${width}`"
    :disabled="disabled"
    :placeholder="placeholder"
  >
  </el-input-number>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import mixin from './mixin-input'

export default defineComponent({
  name: 'jy-number',
  props: {
    modelValue: {
      required: true
    },
    // 是否启用控制按钮
    controls: {
      type: Boolean,
      default: true
    },
    // 最小值
    min: {
      type: Number,
      default: -Infinity
    },
    // 最大值
    max: {
      type: Number,
      default: Infinity
    },
    // 每次递增
    step: {
      type: Number,
      default: 1
    },
    // 小数点精度
    precision: {
      type: Number,
      default: 0
    },
    // 输入框宽度
    width: {
      type: String,
      default: '200px'
    },
    // 是否失效
    disabled: {
      type: Boolean,
      default: false
    },
    // 默认占位文本
    placeholder: {
      type: String,
      default: '请输入'
    }
  },
  emits: ['input', 'update:modelValue'],
  setup (props, context) {
    // mixins 混入
    const { value, changeVal } = mixin(props, context)
    
    return {
      value,
      changeVal
    }
  }
})
</script>
<style lang="less" scoped>
  .el-input-number :deep(.el-input__inner){
    text-align: left;
  }
</style>
